package com.activenetwork.smlite.testcase.login;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;

import com.activenetwork.smlite.page.LoginErrorPage;
import com.activenetwork.smlite.testcase.BaseCase;
import com.activenetwork.util.EnvContext;
import com.activenetwork.util.PageLoader;
import com.activenetwork.util.RandomString;
import com.activenetwork.util.verification.gson.FailurePoint;

public class Login002 extends BaseCase {
	static final Logger logger = LoggerFactory.getLogger(Login002.class);
	
	@Test
	public void Username_text_input_field_length_validation(){
		
		// No minimum, try no user name
		loginBusiness.login("", "password");
		LoginErrorPage loginErrorPage = PageLoader.load(LoginErrorPage.class);
		if(!StringUtils.equalsIgnoreCase(loginErrorPage.getErrorMsg(), "Please provide a username and password to login.")){
			EnvContext.failurePointTL.get().add(new FailurePoint(
					Login002.class.getName(), 
					"Verify no user name login", 
					"The error message is not correct."));
		}
		
		// user name > 150 chars
		String userName = RandomString.generateRandomString(132);
		userName = userName + "@activenetwork.com";
		loginBusiness.login(userName, "password");
		loginErrorPage = PageLoader.load(LoginErrorPage.class);
		if(!StringUtils.equalsIgnoreCase(loginErrorPage.getErrorMsg(), "Username or Password is not correct.")){
			EnvContext.failurePointTL.get().add(new FailurePoint(
					Login002.class.getName(), 
					"Verify user name length", 
					"The error message is not correct."));
		}
		
		loginBusiness.logout();
		
	}
	
	

}
